package com.song;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

import java.util.concurrent.TimeUnit;

/**
 * @Author 宋伟宁
 * @Date 2024/1/3
 * @Version 1.0
 **/
@SpringBootApplication
@EnableDiscoveryClient
public class OrderApplication8000 {
    public static void main(String[] args) throws InterruptedException {

        ConfigurableApplicationContext context = SpringApplication.run(OrderApplication8000.class, args);
        while(true) {
            String name = context.getEnvironment().getProperty("user.username");
            String pwd = context.getEnvironment().getProperty("user.password");
            System.out.println(name);
            System.out.println(pwd);
            TimeUnit.SECONDS.sleep(100);
        }
    }



    @Bean
    @LoadBalanced // 开启负载均衡（默认是轮询机制）
    public RestTemplate restTemplate(RestTemplateBuilder builder){
        return builder.build();
    }
}
